// 经典分组背包问题
// f[i][j] = max(f[i - 1][j], f[i - 1][j - v] + w, f[i - 1][j - 2v] + 2w, ...)
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 6050;
int f[N], n, m;
int main()
{
    cin >> n >> m;
    while (n--)
    {
        int v, w, s;
        cin >> v >> w >> s;
        for (int j = m; j >= v; --j)
            for (int k = 1; k <= s && j - k * v >= 0; ++k)
                f[j] = max(f[j], f[j - k * v] + k * w);
    }
    cout << f[m] << endl;
    return 0;
}